MACRO(STATECHARTLIB_NOLIST
  name
  sources
  includes)

  # Gather all headers
  FILE(GLOB_RECURSE INC_ALL *.h)
     
  INCLUDE_DIRECTORIES(${includes})
  ADD_LIBRARY(${name} ${INC_ALL} ${sources})

  # Group by location on disk
  SOURCE_GROUP(Files FILES CMakeLists.txt)
  SET(ALL_FILES ${sources} ${INC_ALL})
  FOREACH(SRC ${ALL_FILES})
    STRING(REGEX REPLACE ${CMAKE_CURRENT_SOURCE_DIR} "Files" REL_DIR "${SRC}")
    STRING(REGEX REPLACE "[\\\\/][^\\\\/]*$" "" REL_DIR "${REL_DIR}")
    STRING(REGEX REPLACE "^[\\\\/]" "" REL_DIR "${REL_DIR}")
    IF(REL_DIR)
      SOURCE_GROUP(${REL_DIR} FILES ${SRC})
    ELSE(REL_DIR)
      SOURCE_GROUP(Files FILES ${SRC})
    ENDIF(REL_DIR)
  ENDFOREACH(SRC)

  MESSAGE(STATUS "Configuring library ${name}")
ENDMACRO(STATECHARTLIB_NOLIST)

MACRO(STATECHARTLIB
  name
  sources
  includes)

  STATECHARTLIB_NOLIST(${name} "${sources}" "${includes}")

  # Add to blender's list of libraries
  FILE(APPEND ${CMAKE_BINARY_DIR}/cmake_statechart_libs.txt "${name};")
ENDMACRO(STATECHARTLIB)
